﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Homework8
{
    public delegate void ClickHandle(object sender);
    public partial class ReviseForm : Form
    {
        public Orders.OrderService orderService;
        public event ClickHandle ReviseClick;
        public ReviseForm()
        {
            InitializeComponent();
        }

        public void GetOrderList(Orders.OrderService orderService)
        {
            this.orderService = orderService;
        }
        private void button1_Click(object sender, EventArgs e)
        {

            try
            {
                Orders.Order targetOrder = orderService.InquiryOrderByNum(Int32.Parse(textBox1.Text));
                label5.Text = targetOrder.Customer.Name;
            }
            catch (Exception)
            {
                new ReviseWarningForm().ShowDialog();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox3.Text != "")
                orderService.ReviseOrderByClient(Int32.Parse(textBox1.Text), new Orders.Customer(textBox3.Text));
            ReviseClick(this);
            this.Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
